package com.congee02;

public class Rob_TL {

    public int rob(int[] nums) {
        return process(nums, 0);
    }

    private int process(int[] nums, int index) {
        if (index < 0) {
            return 0;
        }
        if (index >= nums.length) {
            return 0;
        }

        int rob = nums[index] + process(nums, index + 2);
        int notRob = process(nums, index + 1);

        return Math.max(rob, notRob);
    }

}
